Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graph-data-structure

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-data-structure

A graph data structure with topological sort.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
215K
increased by7.6%
Maintainers
1
Weekly downloads
 
Created

What is graph-data-structure?

The graph-data-structure npm package provides a simple and efficient way to create and manipulate graph data structures in JavaScript. It supports various graph operations such as adding nodes and edges, finding paths, and detecting cycles.

What are graph-data-structure's main functionalities?

Add Nodes and Edges

This feature allows you to add nodes and edges to the graph. The code sample demonstrates how to create a graph, add nodes 'A' and 'B', and then add an edge from 'A' to 'B'.

const Graph = require('graph-data-structure');
const graph = Graph();
graph.addNode('A');
graph.addNode('B');
graph.addEdge('A', 'B');
console.log(graph.serialize());

Find Paths

This feature allows you to find paths between nodes in the graph. The code sample demonstrates how to find a path from node 'A' to node 'C' through node 'B'.

const Graph = require('graph-data-structure');
const graph = Graph();
graph.addNode('A');
graph.addNode('B');
graph.addNode('C');
graph.addEdge('A', 'B');
graph.addEdge('B', 'C');
const path = graph.path('A', 'C');
console.log(path);

Detect Cycles

This feature allows you to detect cycles in the graph. The code sample demonstrates how to detect a cycle in a graph where nodes 'A', 'B', and 'C' form a cycle.

const Graph = require('graph-data-structure');
const graph = Graph();
graph.addNode('A');
graph.addNode('B');
graph.addNode('C');
graph.addEdge('A', 'B');
graph.addEdge('B', 'C');
graph.addEdge('C', 'A');
const hasCycle = graph.hasCycle();
console.log(hasCycle);

Other packages similar to graph-data-structure

Keywords

FAQs

Package last updated on 21 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc